package framework;

import java.util.HashMap;
import java.util.Map;

import framework.account.BaseAccount;
import framework.account.IAccount;
import framework.account.Transaction;
import framework.command.ICommand;
import framework.observer.BaseObserver;

/**
 * This class intended to provide access to framework subsystem classes, store
 * all customers, and manage subsystem
 * 
 * @author Abdulaziz Ergashev
 * 
 */
public class BaseManager {
	private static BaseManager instance;
    /**
	 * @uml.property  name="observers"
	 * @uml.associationEnd  qualifier="getName:java.lang.String java.util.Observer"
	 */
	private  Map<String, BaseObserver> observers;

	private BaseManager() {
	//	this.customers = new ArrayList<BaseCustomer>();
		this.observers = new HashMap<String, BaseObserver>();
	}

	public void registerObservers(IAccount acc){
		if(observers.get(acc.getClass().getName())!=null){
		  acc.addBaseObserver(observers.get(acc.getClass().getName()));
		}
	}
	

	public <T extends BaseAccount, E extends Transaction> void  attachObserver(BaseObserver<T,E> obs, String className) {
		observers.put(className, obs);
	}
	public static BaseManager getInstance(){
		if(instance == null){
			instance = new BaseManager();
		}
		return instance;
	}
	public void execute(ICommand command){
		command.execute();
	}
}
